Skip to content

[core] Use automatic build tree detection for all resource directories#21018

Open
guitargeek wants to merge 3 commits into
root-project:masterfrom
guitargeek:ignoreprefix
Open

[core] Use automatic build tree detection for all resource directories#21018
guitargeek wants to merge 3 commits into
root-project:masterfrom
guitargeek:ignoreprefix

Conversation

@guitargeek

@guitargeek guitargeek commented Jan 25, 2026

Copy link
Copy Markdown
Contributor

This follows up on a5b1ed9, using the mechanism to automatically detect if we are in the build tree or install tree also for the other resource directories (so far it was only implemented for the include directory as a first test).

Several fallbacks and hacks can be removed because of this change, like the ROOTIGNOREPREFIX variable that was needed to run ROOT in the build tree for the tests.

This change also makes ROOT completely independent of the ROOTSYS environment variable and therefore unblocks #20006.

If one wants to check that all the resource directories (inlcuding RootSys()) are correct, one can use this check:

void checkdirs() {

    std::cout << "Bin       : " << gROOT->GetBinDir() << std::endl;
    std::cout << "Data      : " << gROOT->GetDataDir() << std::endl;
    std::cout << "Doc       : " << gROOT->GetDocDir() << std::endl;
    std::cout << "Etc       : " << gROOT->GetEtcDir() << std::endl;
    std::cout << "Icon      : " << gROOT->GetIconPath() << std::endl;
    std::cout << "Include   : " << gROOT->GetIncludeDir() << std::endl;
    std::cout << "Lib       : " << gROOT->GetLibDir() << std::endl;
    std::cout << "Macro     : " << gROOT->GetMacroDir() << std::endl;
    std::cout << "RootSys   : " << gROOT->GetRootSys() << std::endl;
    std::cout << "SharedLib : " << gROOT->GetSharedLibDir() << std::endl;
    std::cout << "TTFFont   : " << gROOT->GetTTFFontDir() << std::endl;
    std::cout << "Tutorial  : " << gROOT->GetTutorialDir() << std::endl;
}

@guitargeek guitargeek self-assigned this Jan 25, 2026
@guitargeek guitargeek requested a review from pcanal as a code owner January 25, 2026 15:04
@guitargeek guitargeek added in:Core Libraries clean build Ask CI to do non-incremental build on PR labels Jan 25, 2026
@guitargeek guitargeek force-pushed the ignoreprefix branch 3 times, most recently from 82f684f to 5bd24d2 Compare January 25, 2026 17:40
@guitargeek guitargeek requested a review from couet as a code owner January 25, 2026 17:40
@github-actions

github-actions Bot commented Jan 25, 2026

Copy link
Copy Markdown

Test Results

    21 files      21 suites   3d 20h 48m 28s ⏱️
 3 866 tests  3 841 ✅   1 💤 24 ❌
73 528 runs  73 270 ✅ 232 💤 26 ❌

For more details on these failures, see this check.

Results for commit 6dde01e.

♻️ This comment has been updated with latest results.

@guitargeek guitargeek marked this pull request as draft January 26, 2026 08:51
@guitargeek guitargeek force-pushed the ignoreprefix branch 2 times, most recently from 9658e4c to e3a4c50 Compare January 26, 2026 15:54
Comment thread core/base/src/TSystem.cxx Outdated
@vepadulano

Copy link
Copy Markdown
Member

https://github.com/root-project/root/actions/runs/21481040637/job/61888781030?pr=21018#step:7:18 This error probably means that ROOT cannot even start and the process segfaults.

@guitargeek

Copy link
Copy Markdown
Contributor Author

https://github.com/root-project/root/actions/runs/21481040637/job/61888781030?pr=21018#step:7:18 This error probably means that ROOT cannot even start and the process segfaults.

This is fixed by that PR:

@guitargeek guitargeek force-pushed the ignoreprefix branch 2 times, most recently from 84ea7d7 to 160e5f1 Compare March 2, 2026 10:52
@guitargeek guitargeek force-pushed the ignoreprefix branch 2 times, most recently from 000a6bd to 180ebb0 Compare April 18, 2026 14:17
@guitargeek guitargeek force-pushed the ignoreprefix branch 5 times, most recently from 489b683 to 6c6dee9 Compare April 26, 2026 20:59
@guitargeek guitargeek marked this pull request as ready for review April 27, 2026 07:49
This is to test that ROOT doesn't get confused at build and test time by
the fact that the structure of the install tree and build tree is
different, which is the case for `gnuinstall=ON`.
@pcanal

pcanal commented Jun 18, 2026

Copy link
Copy Markdown
Member

Updating master merge/rebase point

@pcanal pcanal reopened this Jun 18, 2026
@@ -1,15 +1,14 @@
/* This file is automatically generated */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this file manually, so arguably the file is not automatically generated anymore. Also how did this comment help without saying how the file was automatically generated? 🙂

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is one off in this context :). The file compiledata.win32.in is hand written but used as a template for the generation of compiledata.h and in the that file the comment is accurate :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh okay I get what you mean now! I'll add the comment back

Comment thread core/base/src/TROOT.cxx Outdated
Comment thread core/base/src/TROOT.cxx Outdated
Comment thread core/base/CMakeLists.txt
endif()
file(RELATIVE_PATH install_lib_to_include "${libdir}" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
unset(libdir)
file(RELATIVE_PATH _rel "${libdir}" "${install_dir_absolute}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if libdir and install_dir_absolute are both absolute and unrelated (weird installation where one of the directory is being installed in an unusual place).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keeps things simple and branch-free: every resource directory is encoded as a path relative to libdir, resolved at runtime against the actual location of libCore. So the whole install tree stays relocatable as long as its internal layout is preserved.

There might be corner cases where different behavior is preferable, e.g. an some absolute resource directory like /usr/etc directory outside the install prefix that you expect to stay fixed even when the build is relocated. There, a relative path would be wrong. But I think that's a pathological case we Shouldn't support unless a user actually asks for it.

To be fair, this would have worked before with gnuinstall=ON, because all resource directories were absolute in that case, but that also means gnuinstall=ON builds weren't relocatable. One of my goals here was to unify the gnuinstall=ON and gnuinstall=OFF behavior so they only differ by the CMAKE_INSTALL_<…> paths. So if you want relocatable builds and not too many if-else branches in the CMake, what's in the PR is the result..

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really do not have a good handle on whether the feature is or is not used (I do have some recollection of using stashing the etc and/or share directory 'somewhere' else). Unless I can re-find the user I am thinking of (and maybe even if), we really should "explicitly" error out if we can detect the issue.

@guitargeek guitargeek force-pushed the ignoreprefix branch 2 times, most recently from 16434df to e697135 Compare June 18, 2026 18:49
This follows up on a5b1ed9, using the mechanism to automatically
detect if we are in the build tree or install tree also for the other
resource directories (so far it was only implemented for the `include`
directory as a first test).

Several fallbacks and hacks can be removed because of this change, like
the `ROOTIGNOREPREFIX` variable that was needed to run ROOT in the build
tree for the tests.
Example of how the warning looks like if it happens:
```txt
[I] omen nix-shell ~/c/r/root_build > ROOTSYS=/home/rembserj/ ./bin/root
Warning in <TROOT>: ROOTSYS is set but inconsistent with detected ROOT installation:
   ROOTSYS=/home/rembserj/
   Detected=/home/rembserj/code/root/root_build
ROOT will use the detected installation.
   ------------------------------------------------------------------
  | Welcome to ROOT 6.41.01                        https://root.cern |
  | (c) 1995-2025, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Jan 01 1980, 00:00:00                 |
  | From heads/ignoreprefix@v6-99-99-368-gd1d33ba04be                |
  | With clang version 21.1.8 std202002                              |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q'  |
   ------------------------------------------------------------------

root [0]
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-python-wheels Run the workflow to build Python wheels clean build Ask CI to do non-incremental build on PR in:Build System in:Core Libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants